$(function(){
	
//	$("#jgrowl").click(function (){$.jGrowl('dddddddddddddddddd');});
		/* ############## upload file ################ */
	var button = $('#upload'), interval;
		
	new AjaxUpload(button, {
		action: '/fileUploader/process', 
		name: 'file',
		responseType: 'json',
		data : {
			'upload' : "attachments", 
			'successAction' : "upload",
			'successController' : "multimedia",
			'errorAction' : "upload",
			'errorController' : "multimedia"
		}, 

		onSubmit : function(file, ext){
			// change button text, when user selects file
		  
				$.jGrowl('开始上传！');
							
			// If you want to allow uploading only 1 file at time,
			// you can disable upload button
			this.disable();
			
//			// Uploding -> Uploading. -> Uploading...
//			interval = window.setInterval(function(){ 
//					$.jGrowl('上传中...'); 
//			}, 200);
		},
		onComplete: function(file, response){ 
			
			//window.clearInterval(interval);
			$.jGrowl("上传成功！");
			// enable upload button
			this.enable();
		 
			if (response.success)
			{	// add file to the list
				$('#multimediafile').append("<div><img src='"+response.message.url+"'><input type='hidden' name='multimedia' value='"+response.message.id+"'></div>");
		   
			}else{
				$.jGrowl(response.message);
			}
		}
	});

});

  